package com.orphan.util.AuditMQ;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AuditInfoMq {
    @Autowired
    CachingConnectionFactory cachingConnectionFactory;
//    @Bean(value = "rabbitTemplate")
//    public RabbitTemplate rabbitTemplate(){
//        return new RabbitTemplate(cachingConnectionFactory);
//    }
//创建队列
   @Bean
    public Queue queueaudit(){
       return new Queue("queueaudit");
    }
    //创建默认交换机
    @Bean
    public DirectExchange directExchangeaudit(){
        return new DirectExchange("directExchangeaudit" );
    }
    //把队列绑定到交换机
    @Bean
    public Binding supplierAuditExchange(Queue queueaudit, DirectExchange directExchangeaudit){
        return BindingBuilder.bind(queueaudit).to(directExchangeaudit).with("audit");
    }


    //创建队列
    @Bean
    public Queue queueaudit1(){
        return new Queue("queueaudit1");
    }
    //创建默认交换机
    @Bean
    public DirectExchange directExchangeaudit1(){
        return new DirectExchange("directExchangeaudit1" );
    }
    //把队列绑定到交换机
    @Bean
    public Binding supplierAuditExchange1(Queue queueaudit1, DirectExchange directExchangeaudit1){
        return BindingBuilder.bind(queueaudit1).to(directExchangeaudit1).with("audit1");
    }
}
